package com.hcrazy.manchester.app.services;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.hcrazy.manchester.app.jdbc.ForumRuleDAO;
import com.hcrazy.manchester.app.jdbc.UserGroupDAO;
import com.hcrazy.manchester.app.pojo.ForumRule;
import com.hcrazy.manchester.app.pojo.UserGroup;

public class InitService {

	private ForumRuleDAO forumRuleDAO;
	
	public ForumRuleDAO getForumRuleDAO() {
		return forumRuleDAO;
	}

	public void setForumRuleDAO(ForumRuleDAO forumRuleDAO) {
		this.forumRuleDAO = forumRuleDAO;
	}
	
	private UserGroupDAO userGroupDAO;
	
	public UserGroupDAO getUserGroupDAO() {
		return userGroupDAO;
	}

	public void setUserGroupDAO(UserGroupDAO userGroupDAO) {
		this.userGroupDAO = userGroupDAO;
	}

	public static Map<Integer,ForumRule> forumRules = null;
	
	public static List<UserGroup> userGroups = null;
	
	public void init() throws Exception {
		List<ForumRule> list = forumRuleDAO.listAllRules();
		Map<Integer,ForumRule> map = new HashMap<Integer,ForumRule>();
		for(ForumRule rule:list){
			map.put(rule.getRuleType(), rule);
		}
		forumRules = map;
		
		userGroups = userGroupDAO.listAllGroups();
	}
	
}
